import { useModel } from "umi";

import AddBrand from "../components/brands/Add";
import EditBrand from "../components/brands/Edit";

const useHelperBrand = () => {
	const { setModalVisible, setModalTitle, setModalWidth, setModalComponent } = useModel("global.modal");

	const openCreateBrandModal = ({ reloadData }) => {
		setModalTitle("新增合作品牌");
		setModalVisible(true);
		setModalWidth(500);
		setModalComponent(<AddBrand reloadData={reloadData} />);
	};

	const openEditBrandModal = ({ reloadData, brand }) => {
		setModalTitle("编辑合作品牌");
		setModalVisible(true);
		setModalWidth(500);
		setModalComponent(<EditBrand reloadData={reloadData} brand={brand} />);
	};

	return { openCreateBrandModal, openEditBrandModal };
};

export default useHelperBrand;
